import request from "@/lib/request";

const serviceName = '/order';

// 创建小程序码参数scene
export const createScene = (data, type) => {
	if (!type) type = "transient";
	return request.POST({
		url: `${serviceName}/openapi/mpwx/qrcode/scene?type=${type}`,
		data: data
	})
}

// 获取二维码参数源参数，临时的scene会删除
export const getSceneData = (scene) => {
	return request.GET({
		url: `${serviceName}/openapi/mpwx/qrcode/scene/${scene}`
	})
}

// 获取二维码参数源参数，临时的scene会删除
export const getSceneImg = (scene, params) => {
	return request.GET({
		url: `${serviceName}/openapi/mpwx/qrcode/scene/${scene}.jpg`,
		data: params
	})
}

// 用户登录（账号密码）
export const mpwxForceLogin = (params) => {
	return request.POST({
		url: `${serviceName}/openapi/user/login/force`,
		data: params
	})
}

//48小时之内是否存在订单明细
export const isServiceItemDetail = (params) => {
	return request.GET({
		url: `${serviceName}/inner/orderItemDetail/isServiceItemDetail`,
		data: params
	})
}

//48小时内为指定用户提供过专陪服务的护理员列表
export const getCareWorkerQueryList = (params) => {
	return request.GET({
		url: `${serviceName}/inner/orderItemDetail/careWorkerQueryList`,
		data: params
	})
}

// 获取患者列表
export const getPatientList = (params) => {
	return request.GET({
		url: `${serviceName}/inner/patient/list`,
		data: params
	})
}

// 服务地址列表
export const getUserAddress = () => {
	return request.GET({
		url: `${serviceName}/inner/userAddress/page`
	})
}

// 服务地址详情
export const getUserAddressDetail = (id) => {
	return request.GET({
		url: `${serviceName}/inner/userAddress/${id}`
	})
}

// 新增服务地址
export const addUserAddress = (params) => {
	return request.POST({
		url: `${serviceName}/inner/userAddress`,
		data: params
	})
}

// 修改服务地址
export const editUserAddress = (id, params) => {
	return request.PUT({
		url: `${serviceName}/inner/userAddress/${id}`,
		data: params
	})
}

// 删除服务地址
export const deleteUserAddress = (id) => {
	return request.DELETE({
		url: `${serviceName}/inner/userAddress/${id}`
	})
}

// 获取二维码参数源参数，临时的scene会删除
export const getQrcodeScene = (scene, params) => {
	return request.GET({
		url: `${serviceName}/openapi/mpwx/qrcode/scene/${scene}`,
		data: params
	})
} 

// 用户端订单列表（包含轻陪,住院陪护,护士上门）
export const getOrderList = (params) => {
	return request.GET({
		url: `${serviceName}/inner/user/allOrderList`,
		data: params
	})
}

//查询医院是否开启了his
export const getHospitalHasHis = (params,hospitalId) => {
	return request.GET({
		url: `${serviceName}/inner/hospital/${hospitalId}/hasHis`,
		data: params
	})
}

//查询项目点是否开启了his
export const getProjectPointHasHis = (params,projectPointCode) => {
	return request.GET({
		url: `${serviceName}/inner/projectPoint/code/${projectPointCode}/hasHis`,
		data: params
	})
}

//根据住院号获得病人信息
export const getHospitalHisInfo = (params,projectPointCode,hospitalNumber) => {
	return request.GET({
		url: `${serviceName}/inner/projectPoint/code/${projectPointCode}/patient/hospitalNumber/${hospitalNumber}/info`,
		data: params
	})
}

// 用户历史发票(用户端)
export const getHistoricalInvoices = (params) => {
	return request.GET({
		url: `${serviceName}/inner/invoiceInformation/historicalInvoices`,
		data: params
	})
}

// 开票管理中的发票管理详情
export const getinvoiceInformationId=(id,params)=>{
	return request.GET({
		url: `${serviceName}/inner/invoiceInformation/${id}`,
		data: params
	})
}
// 开票管理中的发票关联服务分页
export const getinvoiceRelatedOrdePager=(params)=>{
	return request.GET({
		url: `${serviceName}/inner/invoiceRelatedOrder/page`,
		data: params
	})
}

// 判断当前下单账号是否存在相同的患者
export const isExistUserPatient=(userId, patientName, params)=>{
	return request.GET({
		url: `${serviceName}/inner/order/isExistUserPatient/${userId}/${patientName}`,
		data: params
	})
}
